import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object WordCount {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
    conf.setAppName("WordCount")
    conf.setMaster("local")
    val sc = new SparkContext(conf)

    val lineRdd: RDD[String] = sc.textFile("spark/data/sql/words.txt")

    lineRdd
      .flatMap(_.split(","))
      .map(word => (word, 1))
      .reduceByKey(_ + _)
      .foreach(println)

  }
}
